#[derive(Debug, Clone, Copy, PartialEq)]
pub enum ContextValues {
    ObjectKey,
    ObjectValue,
    Array,
}

pub struct JsonContext {
    context: Vec<ContextValues>,
    current: Option<ContextValues>,
    empty: bool,
}

impl JsonContext {
    pub(crate) fn default() -> JsonContext {
        JsonContext {
            context: Vec::new(),
            current: None,
            empty: true,
        }
    }
}

impl JsonContext {
 pub     fn new() -> Self {
        JsonContext {
            context: Vec::new(),
            current: None,
            empty: true,
        }
    }

    pub fn set(&mut self, value: ContextValues) {
        self.context.push(value);
        self.current = Some(value);
        self.empty = false;
    }

   pub   fn reset(&mut self) {
        if let Some(_) = self.context.pop() {
            self.current = self.context.last().copied();
            if self.context.is_empty() {
                self.empty = true;
            }
        } else {
            self.current = None;
            self.empty = true;
        }
    }
}

fn main() {
    let mut context = JsonContext::new();

    context.set(ContextValues::ObjectKey);
    println!("Current: {:?}, Empty: {}", context.current, context.empty); // Current: Some(ObjectKey), Empty: false

    context.set(ContextValues::ObjectValue);
    println!("Current: {:?}, Empty: {}", context.current, context.empty); // Current: Some(ObjectValue), Empty: false

    context.reset();
    println!("Current: {:?}, Empty: {}", context.current, context.empty); // Current: Some(ObjectKey), Empty: false

    context.reset();
    println!("Current: {:?}, Empty: {}", context.current, context.empty); // Current: None, Empty: true
}